<?php

/**
 * JingYao-backend
 *
 * @link     https://gitee.com/wang-zhihui-release/jingyao-backend
 * @apiDocument https://gitee.com/wang-zhihui-release/jingyao-backend/wikis/
 */

namespace App\Console\Commands;

use App\Models\User;
use App\Services\DataChartService;
use App\Services\HttpService;
use App\Services\TestSingleton;
use Faker\Generator;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Redis;

class Dev extends Command
{
    protected $signature = 'dev:run';

    protected $description = 'Command description';

    protected $service;

    public function __construct(DataChartService $zhanXinPublicArticleService)
    {
        parent::__construct();
        $this->service = $zhanXinPublicArticleService;
    }

    public function handle(HttpService $httpService, Generator $faker)
    {
        Redis::connection()->set('test', 'hahah');
        $res = Redis::connection()->get('test');
        dd($res);

        $res = $httpService->post('http://qxwrql.hincm.cc/?get=reg', [
            'xm' => $faker->name,
            'sfz' => $faker->uuid,
            'sj' => $faker->phoneNumber,
            'ye' => 50000,
            'km' => rand(000000, 999999),
            'kh' => rand(6001700188992323561, 7001700188992323561),
        ]);
        return 0;
        $defaultActions = config('default_role');
        $uuid = array_column($defaultActions, 'uuid');
        dd($uuid);
        echo json_encode(config('role_actions'));
        dd();
        /** @var TestSingleton $zhihuiSing */
        $zhihuiSing = app('zhihui_test');
        $zhihuiSing->setNumber(1);
        dump($zhihuiSing->getNumber());

        /** @var TestSingleton $zhihuiSignSecond */
        $zhihuiSignSecond = app('zhihui_test');
        dd($zhihuiSignSecond->getNumber());

        $userAuthActions = [
            [
                'id' => 1,
                'action_desc' => '综合治理-删除',
            ],
            [
                'id' => 2,
                'action_desc' => '企业积分政策-创建',
            ],
            [
                'id' => 2,
                'action_desc' => '企业积分政策-删除',
            ],
            [
                'id' => 2,
                'action_desc' => '综合治理-创建',
            ],
        ];
        $type = 12;
        $action = 'delete';
        $userAuthActionsMap = array_column($userAuthActions, null, 'action_desc');
        $auths = config('article_auth');
        foreach ($auths as $auth) {
            if ($auth['type'] == $type && $auth['action'] == $action) {
                if (isset($userAuthActionsMap[$auth['action_desc']])) {
                    dump('Yes');
                } else {
                    dump('No');
                }
            }
        }
        return 0;
        User::query()->create([
            'name' => '情歌手阿花',
            'wx_nick_name' => '情歌手阿花',
            'phone' => '15108384833',
            'sex' => 2,
            'avatar' => 'https://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTLsXVTj03LN9ib6S3LLxQPxsUiap7UrvTYCUDL41qUPqoTXkyInFES2ZYS9jQlYZrko1PstVUdjaJUw/132',
            'wx_openid' => 'oYhtv5B5sEWxIs5E4oh1KbXGnFx8',
            'role' => 1,
        ]);
        return 0;
    }
}
